// pages/shurupinglun/shurupinglun.js
Page({
  data: {
    height: 20,
    focus: false
  },
  bindButtonTap: function () {
    this.setData({
      focus: true
    })
  },
  bindFormSubmit: function (e) {
    const db = wx.cloud.database()//打开数据库连接
    let shupings = e.detail.value
    this.add(db, shupings) //新增记录
  }, add: function (db, shupings) {
    db.collection("shuping").add({
      data: {
        pinglun: shupings.pinglun
      }, success: res => {
        wx.showToast({
          title: '评论发布成功',
        })
        wx.navigateTo({
          url: '../remenshuping/remenshuping',
        })
      }, fail: err => {
        wx.showToast({
          title: '评论发布失败',
        })
      }
    })

  }


})